home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / BADNAME.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  664b  |  27 lines

  1. ' BADNAME.BAS
  2. ' This program separates first and last names and prints them.
  3. '   Can you find the two logic errors?
  4.  
  5. CLS
  6.  
  7. PRINT "Enter your first and last name in the following format:  ";
  8. PRINT "Lastname, Firstname"
  9. PRINT
  10.  
  11. INPUT "Name:  ", fullName$
  12.  
  13. commaLocation% = INSTR(1, fullName$, ",")
  14.  
  15. IF (commaLocation% < 0) THEN
  16.     lastName$ = LEFT$(fullName$, commaLocation% - 1)
  17.     firstName$ = RIGHT$(fullName$, LEN(fullName$) - commaLocation% - 1)
  18.  
  19.     PRINT
  20.     PRINT "What a lovely name!  It's so nice to meet you, ";
  21.     PRINT firstName$; " "; lastName$; "!"
  22. ELSE
  23.     PRINT
  24.     PRINT "Name not in Lastname, Firstname format."
  25. END IF
  26.  
  27.